import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'
import NewsList from '../views/news/NewsList.vue'
import Detail from '../views/news/Detail.vue'
import PhotoList from '../views/photo/PhotoList.vue'
import Info from '../views/photo/Info.vue'
import GoodsList from '../views/goods/GoodsList.vue'
import GoodsDetail from '../views/goods/GoodsDetail.vue'
import ShopCart from '../views/ShopCart.vue'
import Search from '../views/Search.vue'
import AddGoods from '../views/AddGoods.vue'
import Member from '../views/Member.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    { path: '/', redirect: '/home'},
    { path: '/home', component: Home },
    { path: '/newslist', component: NewsList},
    { path:'/newslist/detail/:id', component: Detail },
    { path: '/photo/list', component: PhotoList },
    { path: '/photo/info/:id', component: Info },
    { path: '/goods/list', component: GoodsList },
    { path: '/goods/detail/:id', component: GoodsDetail },
    { path: '/shopcar', component: ShopCart },
    { path: '/search', component: Search },
    { path: '/addgoods', component: AddGoods },
    { path: '/member', component: Member },
  ]
})
// 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   // to and from are both route objects. must call `next`.
//   if (to.path === '/home') return next()
//   // 获取token
//   const tokenStr = window.sessionStorage.getItem('token')
//   if (!tokenStr) return next('/home')
//   next()
// })
export default router